how to calculate sum of array elements using pointer in c